package com.xx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Suppliers;
import com.xx.mapper.SuppliersMapper;
import com.xx.service.SuppliersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuppliersServiceImpl implements SuppliersService {

    @Autowired
    SuppliersMapper suppliersMapper;

    @Override
    public Suppliers queryById(Integer supplierId) {
        return suppliersMapper.queryById(supplierId);
    }


    //分页
    @Override
    public PageInfo<Suppliers> queryByPage(Suppliers suppliers, Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<Suppliers> list = suppliersMapper.queryAllByLimit(suppliers,pageNum);
        PageInfo<Suppliers> pageInfo =  new PageInfo<>(list);
        return pageInfo;
    }


    @Override
    public int insert(Suppliers suppliers) {
        return suppliersMapper.insert(suppliers);
    }

    @Override
    public int update(Suppliers suppliers) {
        return suppliersMapper.update(suppliers);
    }


    @Override
    public int deleteById(Integer supplierId) {
        return suppliersMapper.deleteById(supplierId);
    }
}
